package weaver.interfaces.ht.duss.cgsq;

import com.sap.mw.jco.IFunctionTemplate;
import com.sap.mw.jco.JCO;
import com.weaver.integration.datesource.SAPInterationOutUtil;
import com.weaver.integration.log.LogInfo;

import java.util.Map;

/**
 * @Title: ecology-9-demo
 * @Company: 泛微软件
 * @author: weaver.Dusongsong
 * @version: 1.0
 * @CreateDate: 2020-06-17
 * @Description: ${description}
 * @ModifyLog:
 **/

public class ZBPM_PR_LIST {
    public JCO.Table  execute(Map<String, String> map) {
        SAPInterationOutUtil outUtil = new SAPInterationOutUtil();
        JCO.Client myConnection = (JCO.Client)outUtil.getConnection("1", new LogInfo());
        myConnection.connect();
        JCO.Repository myRepository = new JCO.Repository("Repository",myConnection); // 只一个名字
        IFunctionTemplate ft = myRepository.getFunctionTemplate("ZBPM_PR_LIST");//设置BAPI函数
        JCO.Function bapi = ft.getFunction();
        JCO.ParameterList input = bapi.getImportParameterList();//输入参数和结构处理
        JCO.ParameterList inputtable = bapi.getTableParameterList();//输入表的处理
        //输入参数
        input.setValue(map.get("I_BANFN"),"I_BANFN");//Prnumber

        //执行函数
        myConnection.execute(bapi);
        JCO.ParameterList out = bapi.getExportParameterList();//输出参数和结构处理
        JCO.ParameterList Table00 = bapi.getTableParameterList();//输出表的处理

        //返回处理结果以及日志
        JCO.Table tabs = Table00.getTable("IT_PR_LIST");
        System.out.println("SPA_COUNTS:"+tabs.getNumRows());
        //返回处理结果以及日志
        JCO.releaseClient(myConnection);
        return tabs;
    }
}
